/**
 * Copyright:  Copyright (c) 2013
 *
 * @FileName		: BSDetailAction.java
 * @PageName		: BS 상세
 * @Date			: 오후 1:30:32
 * @LastModifier	: 최경민
 * @LastModifyDate	: 
 * @LastModifier	: 
 * Change history	:
 */
package com.pulp.management.action;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.opensymphony.xwork2.ActionSupport;
import com.pulp.management.model.ManagementInfo;
import com.pulp.management.service.ManagementService;

/**
 * @author 최경민
 * 
 */
public class BSDetailAction extends ActionSupport {
	private static final long serialVersionUID = -1141144794839679714L;
	private String REQUEST_RESULT = "ok";
	static Logger logger = Logger.getLogger(BSDetailAction.class);

	private String errorCode = "";
	private String page;
	private String total;

	private List<ManagementInfo> bsDetailYearList = null;
	private List<ManagementInfo> bsDetailMonthList = null;

	/**
	 * @return the rEQUEST_RESULT
	 */
	public String getREQUEST_RESULT() {
		return REQUEST_RESULT;
	}

	/**
	 * @param rEQUEST_RESULT the rEQUEST_RESULT to set
	 */
	public void setREQUEST_RESULT(String rEQUEST_RESULT) {
		REQUEST_RESULT = rEQUEST_RESULT;
	}

	/**
	 * @return the logger
	 */
	public static Logger getLogger() {
		return logger;
	}

	/**
	 * @param logger the logger to set
	 */
	public static void setLogger(Logger logger) {
		BSDetailAction.logger = logger;
	}

	/**
	 * @return the errorCode
	 */
	public String getErrorCode() {
		return errorCode;
	}

	/**
	 * @param errorCode the errorCode to set
	 */
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	/**
	 * @return the page
	 */
	public String getPage() {
		return page;
	}

	/**
	 * @param page the page to set
	 */
	public void setPage(String page) {
		this.page = page;
	}

	/**
	 * @return the total
	 */
	public String getTotal() {
		return total;
	}

	/**
	 * @param total the total to set
	 */
	public void setTotal(String total) {
		this.total = total;
	}

	/**
	 * @return the bsDetailYearList
	 */
	public List<ManagementInfo> getBsDetailYearList() {
		return bsDetailYearList;
	}

	/**
	 * @param bsDetailYearList the bsDetailYearList to set
	 */
	public void setBsDetailYearList(List<ManagementInfo> bsDetailYearList) {
		this.bsDetailYearList = bsDetailYearList;
	}

	/**
	 * @return the bsDetailMonthList
	 */
	public List<ManagementInfo> getBsDetailMonthList() {
		return bsDetailMonthList;
	}

	/**
	 * @param bsDetailMonthList the bsDetailMonthList to set
	 */
	public void setBsDetailMonthList(List<ManagementInfo> bsDetailMonthList) {
		this.bsDetailMonthList = bsDetailMonthList;
	}

	/**
	 * @return the serialversionuid
	 */
	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String execute() throws Exception {
		System.out.println("BSDetailAction================");
		HttpServletRequest request = (HttpServletRequest) ServletActionContext.getRequest();

		try {
			ServletContext servletContext = ServletActionContext.getServletContext();
			WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
			ManagementService managementService = (ManagementService) wac.getBean("managementService");
			bsDetailYearList = (List<ManagementInfo>) managementService.getBSDetailYear();
			bsDetailMonthList = (List<ManagementInfo>) managementService.getBSDetailMonth();

			request.setAttribute("bsDetailYearList", bsDetailYearList);
			request.setAttribute("bsDetailMonthList", bsDetailMonthList);

		} catch (Exception e) {
			REQUEST_RESULT = "FALIED";
			e.printStackTrace();
		}
		return REQUEST_RESULT;
	}
}
